package com.escape.oss.adapter;

import com.escape.oss.entity.FileInfo;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.List;

public interface StorageAdapter {

    /**
     * 创建 bucket 桶
     * @param bucketName
     */
    public void createBucket(String bucketName);

    /**
     * 上传文件
     * @param multipartFile
     * @param bucket
     * @param objectName
     * @throws Exception
     */
    public void uploadFile(MultipartFile multipartFile, String bucket, String objectName);

    /**
     * 列出所有桶名
     * @return
     * @throws Exception
     */
    public List<String> getAllBucket();

    /**
     * 列出当前桶的所有文件
     * @param bucket
     * @return
     * @throws Exception
     */
    public List<FileInfo> getAllFile(String bucket);

    /**
     * 下载文件
     * @param bucket
     * @param objectName
     * @return
     * @throws Exception
     */
    public InputStream downloadFile(String bucket, String objectName);

    /**
     * 删除桶
     * @param bucketName
     * @throws Exception
     */
    public void deleteBucket(String bucketName);

    /**
     * 删除文件
     * @param bucket
     * @param objectName
     * @throws Exception
     */
    public void deleteFile(String bucket, String objectName);

}
